package com.itheima.pinda.impl.agency;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.pinda.DTO.entity.pojo.agency.PdAgencyScope;
import com.itheima.pinda.feign.service.agency.PdAgencyScopeService;
import com.itheima.pinda.mapper.agency.PdAgencyScopeMapper;
import com.itheima.pinda.utils.CustomIdGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 机构业务范围表 服务实现类
 * </p>
 *
 * @author xy
 * @since 2021-11-15
 */
@Service
public class PdAgencyScopeServiceImpl extends ServiceImpl<PdAgencyScopeMapper, PdAgencyScope> implements PdAgencyScopeService {

    @Autowired
    private CustomIdGenerator idGenerator;

    /**
     * 批量添加
     * @param dtoList
     * @return
     */
//    @Override
//    public Integer batchSaveAgencyScope(List<AgencyScopeDto> dtoList) {
//
//        if (ObjectUtils.isEmpty(dtoList)){
//            throw new NullPointerException("arstrdytfug");
//        }
//
//        Integer flag = 0;
//        for (AgencyScopeDto agencydto: dtoList
//             ) {
//            agencydto.setId(idGenerator.nextId(agencydto)+"");
//            PdAgencyScope scope = new PdAgencyScope();
//
//            BeanUtils.copyProperties(agencydto,scope);
//            int insert = super.baseMapper.insert(scope);
//            flag = insert+flag;
//        }
//
//        return flag;
//    }

    /**
     * 根据中间表查询
     * @param areaId
     * @param agencyId
     * @param agencyIds
     * @param areaIds
     * @return
     */
//    @Override
//    public List<PdAgencyScope> findAllAgencyScope(String areaId, String agencyId, List<String> agencyIds, List<String> areaIds) {
//        LambdaQueryWrapper<PdAgencyScope> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//        if (!ObjectUtils.isEmpty(areaId)) {
//            lambdaQueryWrapper.eq(PdAgencyScope::getAreaId, areaId);
//        }
//        if (!ObjectUtils.isEmpty(agencyId)) {
//            lambdaQueryWrapper.eq(PdAgencyScope::getAgencyId, agencyId);
//        }
//        if (agencyIds != null && agencyIds.size() > 0) {
//            lambdaQueryWrapper.in(PdAgencyScope::getAgencyId, agencyIds);
//        }
//        if (areaIds != null && areaIds.size() > 0) {
//            lambdaQueryWrapper.in(PdAgencyScope::getAreaId, areaIds);
//        }
//        return baseMapper.selectList(lambdaQueryWrapper);
//    }

    /**
     * 删除agencyscop
     * @param areaId
     * @param agencyId
     */
//    @Override
//    public void deleteAgencyScope(String areaId, String agencyId) {
//        LambdaQueryWrapper<PdAgencyScope> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//        boolean canExecute = false;
//        if (!ObjectUtils.isEmpty(areaId)) {
//            lambdaQueryWrapper.eq(PdAgencyScope::getAreaId, areaId);
//            canExecute = true;
//        }
//        if (!ObjectUtils.isEmpty(agencyId)) {
//            lambdaQueryWrapper.eq(PdAgencyScope::getAgencyId, agencyId);
//            canExecute = true;
//        }
//        if (canExecute) {
//            baseMapper.delete(lambdaQueryWrapper);
//        }
//    }

}
